from ..models.inventory import Inventory

class InventoryService:
    """库存数据处理服务"""
    
    TYPE_MAPPING = {
        'mass_production_material': '量产材料',
        'mass_production_product': '量产成品',
        # 其他类型映射...
    }

    @classmethod
    def get_by_type(cls, material_type):
        """根据类型获取库存数据"""
        if material_type not in cls.TYPE_MAPPING:
            raise ValueError("无效的物料类型")
        
        db_type = cls.TYPE_MAPPING[material_type]
        return [item.to_dict() for item in Inventory.query.filter_by(material_type=db_type).all()]